﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Singer.Framework.CoreDI
{
    [AttributeUsage(AttributeTargets.Class)]
    public class CoreDIAttribute : Attribute
    {
        /// <summary>
        /// 要注入的接口类型
        /// </summary>
        public Type? InterfaceType { get; private set; }
        /// <summary>
        /// 服务的生命周期
        /// </summary>
        public LifeTimeType LifeTimeType { get; private set; }

        public CoreDIAttribute(Type? interfaceType = null, LifeTimeType lifeTimeType = LifeTimeType.Scoped)
        {
            if (!Enum.IsDefined(lifeTimeType)) throw new Exception($"The Enum '{nameof(LifeTimeType)}' value error.");
            InterfaceType = interfaceType;
            LifeTimeType = lifeTimeType;
        }
    }
}
